package com.erdos.message.channel;

import javax.jms.Destination;

import com.erdos.message.entity.MessageChannel;


public class NullMessageChannel extends MessageChannel {
	private static final String NULL_CHANNEL="NULL_CHANNEL";

	private static final NullMessageChannel instance=new NullMessageChannel();
	
	private NullMessageChannel() {
		
	}
	
	public static NullMessageChannel getInstance() {
		return instance;
	}
	
	@Override
	public Destination getChannel() {		
		return NullDestination.getInstance();
	}

	@Override
	public String getDestination() {		
		return NULL_CHANNEL;
	}

	@Override
	public void setDestination(String jndiName) {
		//do nothing
	}

	private static final class NullDestination implements Destination {
		private static final NullDestination dest=new NullDestination();
		private NullDestination() { }
		
		public static NullDestination getInstance() {
			return dest;
		}
		
		@Override
		public boolean equals(Object obj) {
			if(this==obj) {
				return true;
			}
			if(obj==null) {
				return false;
			}
			if (!(obj instanceof NullDestination))
				return false;
			NullDestination rhs=(NullDestination)obj;
			return this.hashCode()==rhs.hashCode();
		}

		@Override
		public int hashCode() {
			return 2008052101;			
		}

		@Override
		public String toString() {			
			return NULL_CHANNEL;
		}
		
	}
}
